package com.sztest.jayjun.dialog;

/*

 */

import android.content.Context;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.TextView;

import com.sztest.jayjun.MyApplication;
import com.sztest.jayjun.R;
import com.sztest.jayjun.dialog.BaseDialog.Base2Dialog;
import com.sztest.jayjun.utils.LogUtils;

import androidx.annotation.NonNull;


public class VolumeDialog extends Base2Dialog {


    private int mVolumeChange;
    private int volumeLev=10;
    private int volume=3;

    public VolumeDialog(@NonNull Context context) {
        super(context);
    }

    public VolumeDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected int getlayoutId() {
        return R.layout.volume_dialog_layout;
    }
    SeekBar seekBar;
    TextView volume_value;
    @Override
    protected void initView() {
        super.initView();
        seekBar = (SeekBar) findViewById(R.id.seekbar);
        seekBar.setMax(volumeLev);
        volume_value = (TextView) findViewById(R.id.volume_value);
        seekBar.setProgress(volume);
        volume_value.setText((volume * 100 / volumeLev) + "%");
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                //  Log.i("TAG", "onProgressChanged=" + progress);
                volume_value.setText((progress * 100 / volumeLev) + "%");

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                //Log.i(TAG,"onStartTrackingTouch=");

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mVolumeChange = seekBar.getProgress();
                if (mVolumeChange == 0) {
                    mVolumeChange = 1;
                    seekBar.setProgress(1);
                    volume_value.setText((1 * 100 / volumeLev) + "%");
                }
                LogUtils.e("  onProgressChanged= " + mVolumeChange);

            }
        });

    }
}
